home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 21 / Cream of the Crop 21 (Terry Blount) (October 1996).iso / comm / msged400.zip / src / dosasm.c < prev    next >
C/C++ Source or Header  |  1996-07-23  |  3KB  |  175 lines

  1. /* Written by Matthew Parker */
  2. /* Released to the public domain */
  3.  
  4. #ifdef __FLAT__
  5. #include <i86.h>
  6. #include "rmi.h"
  7.  
  8. struct rminfo RMINF;
  9. #else
  10. #include <dos.h>
  11. #include <conio.h>
  12. #endif
  13.  
  14. void dospause(void)
  15. {
  16. #ifdef __FLAT__
  17.     int86x(0x28);
  18. #else
  19.     union REGS r;
  20.  
  21.     int86(0x28, &r, &r);
  22. #endif
  23. }
  24.  
  25. void dvpause(void)
  26. {
  27. #ifdef __FLAT__
  28.     RMINF.EAX = 0x101a;
  29.     int86x(0x15);
  30.     RMINF.EAX = 0x1000;
  31.     int86x(0x15);
  32.     RMINF.EAX = 0x1025;
  33.     int86x(0x15);
  34. #else
  35.     union REGS r;
  36.  
  37.     r.x.ax = 0x101a;
  38.     int86(0x15, &r, &r);
  39.     r.x.ax = 0x1000;
  40.     int86(0x15, &r, &r);
  41.     r.x.ax = 0x1025;
  42.     int86(0x15, &r, &r);
  43. #endif
  44. }
  45.  
  46. void winpause(void)
  47. {
  48. #ifdef __FLAT__
  49.     RMINF.EAX = 0x1680;
  50.     int86x(0x2f);
  51. #else
  52.     union REGS r;
  53.  
  54.     r.x.ax = 0x1680;
  55.     int86(0x2f, &r, &r);
  56. #endif
  57. }
  58.  
  59. int dvcheck(void)
  60. {
  61. #ifdef __FLAT__
  62.     RMINF.ECX = 0x4445;
  63.     RMINF.EDX = 0x5351;
  64.     RMINF.EAX = 0x2b01;
  65.     int86x(0x21);
  66.  
  67.     return !((RMINF.EAX & 0xff) == 0xff);
  68. #else
  69.     union REGS r;
  70.  
  71.     r.x.cx = 0x4445;
  72.     r.x.dx = 0x5351;
  73.     r.x.ax = 0x2b01;
  74.     int86(0x21, &r, &r);
  75.  
  76.     return !(r.h.al == 0xff);
  77. #endif
  78. }
  79.  
  80. int kbdhit(void)
  81. {
  82. #ifdef __FLAT__
  83.     RMINF.EAX = 0x100;
  84.     int86x(0x16);
  85.  
  86.     return !(RMINF.flags & INTR_ZF);
  87. #else
  88.     return kbhit()? 1 : 0;
  89. #endif
  90. }
  91.  
  92. unsigned int obtkey(void)
  93. {
  94. #ifdef __FLAT__
  95.     RMINF.EAX = 0;
  96.     int86x(0x16);
  97.     if ((RMINF.EAX & 0xff) == 0)
  98.     {
  99.         return RMINF.EAX & 0xffff;
  100.     }
  101.     else
  102.     {
  103.         return (unsigned)(RMINF.EAX & 0xff);
  104.     }
  105. #else
  106.     union REGS r;
  107.  
  108.     r.x.ax = 0;
  109.     int86(0x16, &r, &r);
  110.     if (r.h.al == 0)
  111.     {
  112.         return r.x.ax;
  113.     }
  114.     else
  115.     {
  116.         return r.h.al;
  117.     }
  118. #endif
  119. }
  120.  
  121. unsigned int dosavmem(void)
  122. {
  123.     union REGS r;
  124.     struct SREGS s;
  125.  
  126.     r.h.ah = 0x48;
  127. #ifdef __FLAT__
  128.     r.w.bx = 0xffff;
  129.     int386(0x21, &r, &r);
  130. #else
  131.     r.x.bx = 0xffff;
  132.     int86(0x21, &r, &r);
  133. #endif
  134.     if (r.x.cflag)
  135.     {
  136. #ifdef __FLAT__
  137.         return r.w.bx;
  138. #else
  139.         return r.x.bx;
  140. #endif
  141.     }
  142.     else
  143.     {
  144. #ifdef __FLAT__
  145.         segread(&s);
  146.         s.es = r.w.ax;
  147. #else
  148.         s.es = r.x.ax;
  149. #endif
  150.         r.h.ah = 0x49;
  151. #ifdef __FLAT__
  152.         int386x(0x21, &r, &r, &s);
  153. #else
  154.         int86x(0x21, &r, &r, &s);
  155. #endif
  156.         return 0xffff;
  157.     }
  158. }
  159.  
  160. #ifdef __FLAT__
  161. void int86x(unsigned short inty)
  162. {
  163.     union REGS regs;
  164.     struct SREGS sregs;
  165.  
  166.     segread(&sregs);
  167.     regs.w.ax = 0x0300;
  168.     regs.w.bx = inty;
  169.     regs.w.cx = 0;
  170.     sregs.es = FP_SEG(&RMINF);
  171.     regs.x.edi = FP_OFF(&RMINF);
  172.     int386x(0x31, ®s, ®s, &sregs);
  173. }
  174. #endif
  175.